package com.fengze.business.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.fengze.common.annotation.Log;
import com.fengze.common.core.controller.BaseController;
import com.fengze.common.core.domain.AjaxResult;
import com.fengze.common.enums.BusinessType;
import com.fengze.business.domain.InquiryManifest;
import com.fengze.business.service.IInquiryManifestService;
import com.fengze.common.utils.poi.ExcelUtil;
import com.fengze.common.core.page.TableDataInfo;

/**
 * 询价清单Controller
 * 
 * @author lug
 * @date 2024-02-01
 */
@RestController
@RequestMapping("/proproject/manifest")
public class InquiryManifestController extends BaseController
{
    @Autowired
    private IInquiryManifestService inquiryManifestService;

    /**
     * 查询询价清单列表
     */
    @PreAuthorize("@ss.hasPermi('proproject:manifest:list')")
    @GetMapping("/list")
    public TableDataInfo list(InquiryManifest inquiryManifest)
    {
        startPage();
        List<InquiryManifest> list = inquiryManifestService.selectInquiryManifestList(inquiryManifest);
        return getDataTable(list);
    }

    /**
     * 导出询价清单列表
     */
    @PreAuthorize("@ss.hasPermi('proproject:manifest:export')")
    @Log(title = "询价清单", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, InquiryManifest inquiryManifest)
    {
        List<InquiryManifest> list = inquiryManifestService.selectInquiryManifestList(inquiryManifest);
        ExcelUtil<InquiryManifest> util = new ExcelUtil<InquiryManifest>(InquiryManifest.class);
        util.exportExcel(response, list, "询价清单数据");
    }

    /**
     * 获取询价清单详细信息
     */
    @PreAuthorize("@ss.hasPermi('proproject:manifest:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(inquiryManifestService.selectInquiryManifestById(id));
    }

    /**
     * 新增询价清单
     */
    @PreAuthorize("@ss.hasPermi('proproject:manifest:add')")
    @Log(title = "询价清单", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody InquiryManifest inquiryManifest)
    {
        return toAjax(inquiryManifestService.insertInquiryManifest(inquiryManifest));
    }

    /**
     * 修改询价清单
     */
    @PreAuthorize("@ss.hasPermi('proproject:manifest:edit')")
    @Log(title = "询价清单", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody InquiryManifest inquiryManifest)
    {
        return toAjax(inquiryManifestService.updateInquiryManifest(inquiryManifest));
    }

    /**
     * 删除询价清单
     */
    @PreAuthorize("@ss.hasPermi('proproject:manifest:remove')")
    @Log(title = "询价清单", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(inquiryManifestService.deleteInquiryManifestByIds(ids));
    }
}
